<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../js/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			table{
				border: 1px solid black;
				margin: 0 auto;
				border-collapse: collapse;
			}
			td{
				border: 1px solid black;
			}
		</style>
		<script type="text/javascript">
			$(function() {
				$("tr:first").css("background-color", "yellow");
				//$("tr:even:gt(0)").css("background-color", "green");
				//$("tr:even:not(:first)").css("background-color", "green");
				$("tr:gt(0):odd").css("background-color", "green");
				
				
				$("#selectAllId").change(function() {
					/*$(".goods").each(function() {
						//$(this).attr("checked", $("#selectAllId").attr("checked"));
						$(this).prop("checked", $("#selectAllId").prop("checked"));
					});*/
					
					$(".goods").prop("checked", $("#selectAllId").prop("checked"));
				});
			});
			
			function selectAll() {
				console.log($("#selectAllId").attr("checked"));//undefined undefined
				console.log($("#selectAllId").prop("checked"));//true  false
				console.log($("#selectAllId").attr("city"));//bj
				console.log($("#selectAllId").prop("city"));//undefined
				$(".goods").each(function() {
					//$(this).attr("checked", $("#selectAllId").attr("checked"));
					$(this).prop("checked", $("#selectAllId").prop("checked"));
				});
			}
		</script>
	</head>
	<body>
		<table>
           <tr>
           		<td><input type="checkbox" city="bj" id="selectAllId" <!--onclick="selectAll()"-->/></td>
           		<td>序号</td><td>名称</td><td>价格</td><td>数量</td>
           </tr>
           <tr>
           		<td><input type="checkbox" class="goods" /></td>
           		<td>1</td><td>htc</td><td>3200</td><td>10</td>
           </tr>
           <tr>
           		<td><input type="checkbox" class="goods"/></td>
           		<td>2</td><td>apple</td><td>4400</td><td>13</td>
           </tr>
           <tr>
           		<td><input type="checkbox" class="goods"/></td>
           		<td>3</td><td>nokia</td><td>2300</td><td>22</td>
           </tr>
           <tr>
           		<td><input type="checkbox" class="goods"/></td>
           		<td>4</td><td>samsung</td><td>3500</td><td>35</td>
           </tr>
           <tr>
           		<td><input type="checkbox" class="goods"/></td>
           		<td>5</td><td>heimei</td><td>2500</td><td>27</td>
           </tr>
        </table>
	</body>
</html>
